const router = require('express').Router();
const db = require('../common/db/db');
// 统一的响应处理
const sendResponse = (res, code, msg, data = null) => {
    const response = { code, msg };
    if (data) response.results = data;
    res.send(response);
};
// http://localhost:3000/api/banner
// 获取banner
router.get('/banner', async (req, res) => {
    try{
        const result =  await db.query('select * from img_banner')
        sendResponse(res, 200, '获取banner成功', result);
    }
    catch(error){
        console.error('获取banner失败:', error);
        sendResponse(res, -1, '获取banner失败');
    }
});

module.exports = router;
